<?php 
 
namespace app\common\model;

use app\common\model\BaseModel;
use app\common\traits\ModelTrait;
use app\common\utils\JsonService;
/**
* This is the model class for table "{ptf_cart}".
*
* @property int $id 购物车表 
* @property int $user_id 用户id 
* @property string $session_id session
* @property int $goods_id 商品id 
* @property string $goods_sn 商品货号
* @property string $goods_name 商品名称
* @property int $market_price 市场价 
* @property int $goods_price 本店价 
* @property int $member_goods_price 会员折扣价 
* @property int $goods_num 购买数量 
* @property int $spec_price_goods_id 规格表ID 
* @property string $spec_key 商品规格key 对应tp_spec_goods_price 表
* @property string $spec_key_name 商品规格组合名称
* @property string $bar_code 商品条码
* @property int $selected 购物车选中状态 
* @property int $add_time 加入购物车的时间 
* @property int $prom_type 0 普通订单,1 限时抢购, 2 团购 , 3 促销优惠 
* @property int $prom_id 活动id 
* @property string $sku sku
*/
class Cart extends BaseModel{

    protected $pk = 'id';
    protected $name = 'cart';

    use ModelTrait;
    protected $autoWriteTimestamp = true;
    //protected $dateFormat = 'Y-m-d';
    //protected $createTime = 'create_time';
    //protected $updateTime = 'update_time';

    /**
    * {@inheritdoc}
    */
    public function attributeLabels()
    {
        return [
            'id' => '购物车表',
            'user_id' => '用户id',
            'session_id' => 'session',
            'goods_id' => '商品id',
            'goods_sn' => '商品货号',
            'goods_name' => '商品名称',
            'market_price' => '市场价',
            'goods_price' => '本店价',
            'member_goods_price' => '会员折扣价',
            'goods_num' => '购买数量',
            'spec_price_goods_id' => '规格表ID',
            'spec_key' => '商品规格key 对应tp_spec_goods_price 表',
            'spec_key_name' => '商品规格组合名称',
            'bar_code' => '商品条码',
            'selected' => '购物车选中状态',
            'add_time' => '加入购物车的时间',
            'prom_type' => '0 普通订单,1 限时抢购, 2 团购 , 3 促销优惠',
            'prom_id' => '活动id',
            'sku' => 'sku',
        ];
    }

    public function getShop(){
        return $this->hasOne('Shop','shop_id','shop_id')->field('shop_id,shop_name');
    }


    public function getGoods(){
        return $this->hasOne('Goods','goods_id','goods_id')->field('goods_id,shop_id,goods_name,goods_sn,shop_price,market_price,cost_price,original_img,goods_type,sales_sum,comment_count,store_count,exchange_integral,give_integral,is_free_shipping,weight');
    }
}


?>